<?php
session_start();

require_once("../database.include.php");

	$username=$_GET["username"];
				
    $sql = "SELECT `invitation_id`, `invited_user_name`, `inviting_user_name`, `group_name` FROM `group_invitation` WHERE `group_name` IN (SELECT `group_name` FROM `group_user` WHERE `user_name` = '" . $username . "') ORDER BY `invitation_id`";
    

    echo "<input type='hidden' id='cancelinviteID' value=''>";
    echo "<table border='1'><tr><td>&nbsp;</td><td>ID</td><td>Invited User</td><td>Inviting User</td><td>Group</td></tr>";
    foreach ($conn->query($sql) as $row) {
    	echo "<tr>";
    	echo "<td><input type='radio' name='invcan' id='invcan' value='" . $row['invitation_id'] . "' onclick=document.getElementById('cancelinviteID').value='" . $row['invitation_id'] . "';></td>";
    	echo "<td>" . $row['invitation_id'] . "</td>";
        echo "<td>" . $row['invited_user_name'] . "</td>";
        echo "<td>" . $row['inviting_user_name'] . "</td>";
        echo "<td>" . $row['group_name'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
	echo "<button onclick=cancelInvite()>Cancel Invite</button>";
?>